import Vue from 'vue'
import Router from 'vue-router'

const index = () =>
	import('../page/index.vue')
const fullScreen = () =>
	import('../page/fullScreen.vue')
const orgFullScreen = () =>
	import('../page/orgFullScreen.vue')
//登录
const login = () =>
	import('../components/login.vue')
//邮箱绑定
const emailBbinding = () =>
	import('../components/emailBbinding.vue')
//密码设置
const passReset = () =>
	import('../components/passReset.vue')
//密码找回
const passwordRetrieve = () =>
	import('../components/passwordRetrieve.vue')
	
/************网点************/
//网点首页
const slideindex = () =>
	import('../components/slideindex.vue')
//网点业务类型
const business = () =>
	import('../components/business.vue')
//网点业务类型_index
const businessIndex = () =>
  import('../components/business_index.vue')
//网点业务类型_添加
const businessAdd = () =>
  import('../components/business_add.vue')
//网点业务类型_查看
const businessSee = () =>
import('../components/business_see.vue')
//网点业务类型_编辑
const businessEdit = () =>
  import('../components/business_edit.vue')
//网点业务类型_选择
const businessChoose = () =>
	import('../components/business_choose.vue')
//网点窗口管理
const windowss = () =>
	import('../components/windowss.vue')
//网点窗口管理_index
const windowssIndex = () =>
  import('../components/windowss_index.vue')
//网点窗口管理_add
const windowssAdd = () =>
  import('../components/windowss_add.vue')
//网点窗口管理_see
const windowssSee = () =>
  import('../components/windowss_see.vue')
//网点窗口管理_edit
const windowssEdit = () =>
  import('../components/windowss_edit.vue')
//网点设备管理
const equipment = () =>
  import('../components/equipment.vue')
//网点窗口管理_index
const equipmentIndex = () =>
  import('../components/equipment_index.vue')
//网点窗口管理_add
const equipmentAdd = () =>
  import('../components/equipment_add.vue')
//网点窗口管理_see
const equipmentSee = () =>
  import('../components/equipment_see.vue')
//网点窗口管理_edit
const equipmentEdit = () =>
  import('../components/equipment_edit.vue')
//网点预约规则
const make = () =>
  import('../components/make.vue')
//网点首次进入预约规则
const makeIndex = () =>
  import('../components/makeIndex.vue')
//网点预约记录
const makeReservation = () =>
	import('../components/make-reservation.vue')
//网点预约记录_index
const reservationIndex = () =>
	import('../components/reservation_index.vue')
//网点预约记录详情
const reservationDetail = () =>
	import('../components/reservation_detail.vue')
//网点预约记录修改
const reservationEdit = () =>
	import('../components/reservation_edit.vue')
//网点预约记录黑名单
const reservationBlack = () =>
	import('../components/reservation_black.vue')
//网点统计分析
const analysis = () =>
	import('../components/analysis.vue')
//网点预约须知
const notes = () =>
	import('../components/notes.vue')
	//网点预约须知
const notesAdd = () =>
	import('../components/notesAdd.vue')
//网点用户评价
const evaluate = () =>
	import('../components/evaluate.vue')
//网点用户评价 _index
const evaluateIndex = () =>
		import('../components/evaluate_index.vue')
//网点评价详情
const evaluateDetail = () =>
	import('../components/evaluateDetail.vue')
//网点预约须知编辑
const notesEdit = () =>
	import('../components/notesEdit.vue')

/**************机构**************/
//机构管理员首页
const mechanismIndex = () =>
  import('../components/mechanism_index.vue')
//机构统计分析
const orgAnalysis = () =>
	import('../components/orgAnalysis.vue')
//机构预约规则
const orgMake = () =>
  import('../components/orgMake.vue')
//机构首次进入预约规则
const orgMakeIndex = () =>
  import('../components/orgMakeIndex.vue')
//机构预约须知
const orgNotes = () =>
	import('../components/orgNotes.vue')
//机构预约须知编辑
const orgNotesEdit = () =>
	import('../components/orgNotesEdit.vue')
//机构业务类型
const orgBusiness = () =>
	import('../components/orgBusiness.vue')
//机构业务类型_index
const orgBusinessIndex = () =>
  import('../components/orgBusiness_index.vue')
//机构业务类型_添加
const orgBusinessAdd = () =>
  import('../components/orgBusiness_add.vue')
//机构业务类型_查看
const orgBusinessDetail = () =>
import('../components/orgBusiness_detail.vue')
//机构业务类型_编辑
const orgBusinessEdit = () =>
  import('../components/orgBusiness_edit.vue')
//机构人员管理
const orgPeople = () =>
	import('../components/orgPeople.vue')
//机构人员管理_index
const orgPeopleIndex = () =>
	import('../components/orgPeople_index.vue')
//机构人员管理_添加
const orgPeopleAdd = () =>
	import('../components/orgPeople_add.vue')
//机构人员管理_查看
const orgPeopleDetail = () =>
import('../components/orgPeople_detail.vue')
//机构人员管理_编辑
const orgPeopleEdit = () =>
	import('../components/orgPeople_edit.vue')
//机构网点管理
const orgWebsite = () =>
	import('../components/orgWebsite.vue')
//机构网点管理_index
const orgWebsiteIndex = () =>
	import('../components/orgWebsite_index.vue')
//机构网点管理_添加
const orgWebsiteAdd = () =>
	import('../components/orgWebsite_add.vue')
//机构网点管理_查看
const orgWebsiteDetail = () =>
import('../components/orgWebsite_detail.vue')
//机构网点管理_编辑
const orgWebsiteEdit = () =>
	import('../components/orgWebsite_edit.vue')
//机构评价
const orgEvaluate = () =>
	import('../components/orgEvaluate.vue')
//机构评价 _index
const orgEvaluateIndex = () =>
	import('../components/orgEvaluate_index.vue')
//机构评价详情
const orgEvaluateDetail = () =>
	import('../components/orgEvaluate_detail.vue')
const not404 = () =>
	import('../components/not404.vue')
const G2 = () =>
	import('../components/G2.vue')

Vue.use(Router)
//网点菜单
const admin2 = [
  {
    path: '/slideindex',
    component: slideindex
  },
  {
    path: '/business',
    component: business,
    children:[
      {
        path: '/business/businessindex',
        component: businessIndex,
				meta:{
					keepAlive:true
				}
      },
      {
        path: '/business/businessadd',
        component: businessAdd
      },
      {
        path: '/business/businesssee',
        component: businessSee
      },{
        path: '/business/businessedit',
        component: businessEdit
      },{
        path: '/business/businessechoose',
        component: businessChoose
      }
    ]
  },
  {
    path: '/windowss',
    component: windowss,
    children:[
      {
        path: '/windowss/windowssindex',
        component: windowssIndex
      },
      {
        path: '/windowss/windowssadd',
        component: windowssAdd
      },
      {
        path: '/windowss/windowsssee',
        component: windowssSee
      },{
        path: '/windowss/windowssedit',
        component: windowssEdit
      }
    ]
  },
  {
    path: '/equipment',
    component: equipment,
    children:[
      {
        path: '/equipment/equipmentindex',
        component: equipmentIndex,
				meta:{
					keepAlive:true
				}
      },
      {
        path: '/equipment/equipmentadd',
        component:equipmentAdd
      },
      {
        path: '/equipment/equipmentsee',
        component: equipmentSee
      },{
        path: '/equipment/equipmentedit',
        component:equipmentEdit
      }
    ]
  },
  {
    path: '/make',
    component: make
  },
  {
    path:'/makeIndex',
    component:makeIndex
  },
  {
    path: '/makeReservation',
    component: makeReservation,
		children:[
			{
				path: '/makeReservation/reservationindex',
				component: reservationIndex,
				meta:{
					keepAlive:true
				}
			},
			{
				path: '/makeReservation/reservationDetail',
				component: reservationDetail,
			},
			{
				path: '/makeReservation/reservationEdit',
				component: reservationEdit
			},
			{
				path: '/makeReservation/reservationBlack',
				component: reservationBlack
			}
		]
  },
  {
    path: '/analysis',
    component: analysis
  },
  {
    path: '/notes',
    component: notes
  },
  {
    path: '/evaluate',
    component: evaluate,
		children:[
			{
				path: '/evaluate/evaluateindex',
				component: evaluateIndex,
				meta:{
					keepAlive:true
				}
			},
			{
				path: '/evaluate/evaluateDetail',
				component: evaluateDetail
			}
		]
  },
  {
    path: '/notesEdit',
    component: notesEdit
  },
	{
		path: '/notesAdd',
		component: notesAdd
	}
]
//机构菜单
const admin1 = [
  {
    path: '/mechanismindex',
    component: mechanismIndex,
  },
	{
		path: '/orgAnalysis',
		component: orgAnalysis,
	},
	{
		path: '/orgMake',
		component: orgMake
	},
	{
		path:'/orgMakeIndex',
		component:orgMakeIndex
	},
	{
		path: '/orgBusiness',
		component: orgBusiness,
		children:[
			{
				path: '/orgBusiness/orgBusinessIndex',
				component: orgBusinessIndex,
				meta:{
					keepAlive:true
				}
			},
			{
				path: '/orgBusiness/orgBusinessAdd',
				component: orgBusinessAdd
			},
			{
				path: '/orgBusiness/orgBusinessEdit',
				component: orgBusinessEdit
			},
			{
				path: '/orgBusiness/orgBusinessDetail',
				component: orgBusinessDetail
			}
		]
	},
	{
		path: '/orgPeople',
		component: orgPeople,
		children:[
			{
				path: '/orgPeople/orgPeopleIndex',
				component: orgPeopleIndex,
				meta:{
					keepAlive:true
				}
			},
			{
				path: '/orgPeople/orgPeopleAdd',
				component: orgPeopleAdd
			},
			{
				path: '/orgPeople/orgPeopleEdit',
				component: orgPeopleEdit
			},
			{
				path: '/orgPeople/orgPeopleDetail',
				component: orgPeopleDetail
			}
		]
	},
	{
		path: '/orgWebsite',
		component: orgWebsite,
		children:[
			{
				path: '/orgWebsite/orgWebsiteIndex',
				component: orgWebsiteIndex,
				meta:{
					keepAlive:true
				}
			},
			{
				path: '/orgWebsite/orgWebsiteAdd',
				component: orgWebsiteAdd
			},
			{
				path: '/orgWebsite/orgWebsiteEdit',
				component: orgWebsiteEdit
			},
			{
				path: '/orgWebsite/orgWebsiteDetail',
				component: orgWebsiteDetail
			}
		]
	},
	{
		path: '/orgNotes',
		component: orgNotes
	},
	{
		path: '/orgNotesEdit',
		component: orgNotesEdit
	},
	{
		path: '/orgEvaluate',
		component: orgEvaluate,
		children:[
			{
				path: '/orgEvaluate/orgEvaluateIndex',
				component: orgEvaluateIndex,
				meta:{
					keepAlive:true
				}
			},
			{
				path: '/orgEvaluate/orgEvaluateDetail',
				component: orgEvaluateDetail
			}
		]
	},
  {
  path: '/G2',
  component: G2,
  meta: {
    navigation: ['G2', 'G2']
  }
}]
//权限
function routerComponents() {
  var routerComponents = []
  if(window.sessionStorage.getItem("adminStatus")) { routerComponents = window.sessionStorage.getItem("adminStatus") === "admin2"?admin2:admin1}
  return routerComponents
}

const router =  new Router({
	// mode: 'history',
	routes: [
		{
			path: '/index',
			name: 'index',
			component: index,
			children: routerComponents()
		},

	  {
			path: '*',
			name: 'not404',
			component: not404
		}, {
			path: '/',
			name: 'login',
			component: login
		},
		{
			path: '/emailBbinding',
			name: 'emailBbinding',
			component: emailBbinding
		},
		{
			path: '/passReset',
			name: 'passReset',
			component: passReset
		},
		{
			path: '/passwordRetrieve',
			name: 'passwordRetrieve',
			component: passwordRetrieve
		},
		{
			path: '/page/fullScreen',
			component: fullScreen
		},
		{
			path: '/page/orgFullScreen',
			component: orgFullScreen
		}
	]
})
router['getAdmin'] = routerComponents


export default router
